<template>
	<div class="refresh">
		refresh page

		{{ pending }}

		<div>
			<button @click="refreshPage">刷新</button>
		</div>
	</div>
</template>

<script setup>
	const BASE_URL = 'http://codercba.com:9060/juanpi/api'

	const count = ref(1)

	// 点击刷新时, 是在服务端执行, 客户端不会佛山那个网络请求, 水合之后客户端是可以获取数据的
	const { data, refresh, pending } = useFetch(BASE_URL + '/goods', {
		method: 'POST',
		body: {
			count,
		},
	})

	const refreshPage = () => {
		count.value++
		// refresh() // 刷新请求
	}

	console.log(data.value?.data)
</script>
